package com.business.business.web.web;

import cn.hutool.json.JSONObject;
import com.business.business.common.base.BaseController;
import com.business.business.support.annotaion.Action;
import com.business.business.support.model.RespEntity;
import com.business.business.web.service.CertificateService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;

/**
 * @Author xulumin
 * @Date 2024/3/21 11:14
 * @Version 1.0
 * @Desc 证书表
 */
@Controller
@Action
@RequestMapping(value = "certificate")
public class CertificateController extends BaseController {

    @Resource
    private CertificateService certificateService;

    /**
     * Author: xulumin
     * Date: 2024/3/19
     * Description: 证书新增或者更新
     */
    @PostMapping("addOrUpdateCertificate")
    public RespEntity addOrUpdateCertificate(@RequestBody(required = false) JSONObject jsonObject) throws IllegalAccessException, InstantiationException {
        return certificateService.addOrUpdateCertificate(jsonObject);
    }

    /**
     * Author: xulumin
     * Date: 2024/3/19
     * Description: 获取区域下证书信息列表
     */
    @GetMapping("getCertificateAreaList")
    public RespEntity getCertificateAreaList(@RequestBody(required = false)JSONObject jsonObject) {
        return certificateService.getCertificateAreaList(jsonObject);
    }

    /**
     * Author: xulumin
     * Date: 2024/3/19
     * Description: 获取证书信息列表
     */
    @GetMapping("getCertificateList")
    public RespEntity getCertificateList(@RequestBody(required = false) JSONObject jsonObject) {
        return certificateService.getCertificateList(jsonObject);
    }

    /**
     * Author: xulumin
     * Date: 2024/3/20
     * Description: 获取证书信息
     */
    @GetMapping("getCertificateInfo")
    public RespEntity getCertificateInfo(@RequestBody(required = false) JSONObject jsonObject) {
        return certificateService.getCertificateInfo(jsonObject);
    }

    /**
     * Author: xulumin
     * Date: 2024/3/19
     * Description: 删除证书信息
     */
    @PostMapping("delCertificate")
    public RespEntity delCertificate(@RequestBody(required = false) JSONObject jsonObject) {
        return certificateService.delCertificate(jsonObject);
    }
}
